<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>施工角色添加考勤</title>
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no" />
    <link rel="stylesheet" type="text/css" href="../../css/api.css" />
    <link rel="stylesheet" type="text/css" href="../../css/globle.css" />
    <link rel="stylesheet" type="text/css" href="../../css/bootstrap.min.css" />
    <link rel="stylesheet" type="text/css" href="../../css/common.css" />
    <style>
        body {
            padding-top: 25px;
        }

        span {
            margin: 10px;
        }

        .Tabl {
            height: 50px;
            width: 88%;
            font-size: 14px;
            font-weight: bold;
            text-align: left;
            margin-left: 6%;
        }

        .Td1 {
            color: #B8B8B8;
            width: 110px;
        }

        .Td2 {
            color: #000000;
            text-align: left;
        }

        .Hr {
            height: 1px;
            width: 96%;
            background-color: #B8B8B8;
            margin-left: 2%;
        }

        .Butt {
            border: 1px solid #B8B8B8;
            border-radius: 20px;
            color: #FFFFFF;
            height: 17px;
            width: 17px;
            outline: none;
        }

        .TabImg {
            height: 150px;
            width: 96%;
            margin-left: 2%;
            border: 10px solid #D8D8D8;
        }

        .TdImg1 {
            height: 110px;
            width: 90px;
        }

        .TdImg2 {
            height: 110px;
            width: 90px;
        }

        .ButAdd {
            height: 110px;
            width: 100px;
            font-size: 100px;
            color: #FFFFFF;
            background-color: #B8B8B8;
        }

        .TabL {
            height: 75px;
            width: 88%;
            font-size: 16px;
            font-weight: bold;
            text-align: left;
            margin-left: 6%;
        }

        .ButL {
            height: 40px;
            width: 100%;
            background-color: #1abc9c;
            /* position: fixed; */
            bottom: 0;
        }

        .Td3 {
            text-align: center;
            width: 50%;
        }

        select {
            appearance: none;
            -moz-appearance: none;
            -webkit-appearance: none;
            border: none;
            background: none;
        }
    </style>
</head>
<!-- 施工角色添加考勤 -->

<body>
    <form action="" id="myform">
        <input type="hidden" id="id" name="id">
        <input type="hidden" name="a_tid" id="a_tid">
        <input type="hidden" name="a_area_id" id="a_area_id">
        <input type="hidden" name="a_project_id" id="a_project_id">
        <input type="hidden" name="a_eid" id="a_eid">
        <button style="background-color: #F2F2F2;height: 40px;width: 100%;font-size: 18px;">签到信息</button>
        <table class="Tabl">
            <tr>
                <td class="Td1">日期：</td>
                <td class="Td2">
                    <input id="a_createDate" name="a_createDate" />
                </td>
            </tr>
        </table>
        <hr class="Hr" />
        <table class="Tabl">
            <tr>
                <td class="Td1">施工队伍：</td>
                <td class="Td2">
                    <input id="a_name" name="a_name" />
                </td>
            </tr>
        </table>
        <hr class="Hr" />
        <table class="Tabl">
            <tr>
                <td class="Td1">应到人数：</td>
                <td class="Td2">
                    <input type="number" name="a_should_num" id="a_should_num" />
                </td>
            </tr>
        </table>
        <button style="background-color: #F2F2F2;height: 40px;width: 100%;font-size: 18px;">上午签到信息</button>
        <table class="Tabl">
            <tr>
                <td class="Td1">上午人数：</td>
                <td class="Td2">
                    <input type="number" name="a_am_num" id="a_am_num" />
                </td>
            </tr>
        </table>
        <!-- <hr class="Hr" /> -->
        <table class="Tabl" id="signAmTime">
            <tr>
                <td class="Td1">签到时间：</td>
                <td class="Td2">
                    <input id="a_am_createDate" name="a_am_createDate" readonly />
                </td>
            </tr>
        </table>
        <hr class="Hr" />
        <div style="padding: 10px;">
            <ul class="upload-ul clearfix">
                <li class="upload-pick">
                    <div class="webuploader-container clearfix" id="goodsUpload"></div>
                </li>
                <li>
                    <div id="imgBoxAm" name="a_am_picture"></div>
                </li>
            </ul>
        </div>
        <!-- <button style="background-color: #F2F2F2;height: 40px;width: 100%;font-size: 18px;">下午签到信息</button> -->
        <table class="ButL">
            <tr>
                <td class="Td3">
                    <div style="color: #ffffff;" onclick="postData()">
                        发布
                    </div>
                </td>
            </tr>
        </table>
    </form>
</body>
<script type="text/javascript" src="../../script/vue.js"></script>
<script type="text/javascript" src="../../script/api.js"></script>
<script type="text/javascript" src="../../script/common.js"></script>
<script src="../../script/jquery-1.11.0.min.js"></script>
<script src="../../script/diyUpload1.js"></script>
<script src="../../script/webuploader.js"></script>
<script type="text/javascript">
    //单图片上传方法
    var $tgaUpload = $("#goodsUpload").diyUpload({
        url: BaseServiceUrl + "mobile/attendanceCon/uploadAmImage.json",
        success: function (data) {
            //alert(JSON.stringify(data))
        },
        error: function (err) {
            alert(JSON.stringify(err));
        },
        buttonText: "",
        accept: {
            title: "Images",
            extensions: "gif,jpg,jpeg,bmp,png",
            mimeTypes: 'image/*'
        },
        thumb: {
            width: 600,
            height: 600,
            quality: 100,
            allowMagnify: false,
            crop: false,
            type: "image/jpeg",
        },
    });
    $tgaUpload.options.formData.dids = null;
    var user = $api.getStorage("userSession");
    var areaId = user.data.areaid;
    var proId = user.data.projectid;
    var userId = user.data.id;
    ////企业id
    var enterpriseId = $api.getStorage("userSession").data.enterprise.id;
    var userName = user.data.name
    // alert(userName)
    apiready = function () {
        $("#a_eid").val(enterpriseId)
        $("#a_tid").val(user.data.team_id)
        $("#a_area_id").val(areaId)
        $("#a_project_id").val(proId)
        $("#a_name").val(userName);
        //赋值当日考勤日期
        var thisday = new Date();
        thisday.setTime(thisday.getTime());
        var year = thisday.getFullYear();
        var month = thisday.getMonth() + 1;
        var day = thisday.getDate();
        if (month < 10) {
            month = "0" + month;
        }
        if (day < 10) {
            day = "0" + day;
        }
        var s = year + "-" + month + "-" + day;
        $("#a_createDate").val(s);
        $("#pm").hide()
        $("#signAmTime").hide()
    };

    function postData() {
        var formObject = {};
        var formArray = $("#myform").ghostsf_serialize();
        $.each(formArray, function (i, item) {
            formObject[item.name] = item.value;
        });
        post(JSON.stringify(formObject));
    }

    $.fn.ghostsf_serialize = function () {
        var a = this.serializeArray();
        var $radio = $("input[type=radio],input[type=checkbox]", this);
        var temp = {};
        $.each($radio, function () {
            if (!temp.hasOwnProperty(this.name)) {
                if ($("input[name='" + this.name + "']:checked").length == 0) {
                    temp[this.name] = "";
                    a.push({
                        name: this.name,
                        value: "",
                    });
                }
            }
        });
        return a;
    };

    function post(data) {
        $.ajax({
            type: "post",
            //async : false, //同步执行
            url: BaseServiceUrl + "mobile/attendanceCon/update.json",
            data: {
                data: data
            },
            dataType: "json", //返回数据形式为json
            success: function (result) {
                // alert(JSON.stringify(result))
                $tgaUpload.options.formData.dids = result.obj.id
                $tgaUpload.upload();
                if (result.code == 0) {
                    api.showProgress({
                        //打开开关
                        title: "提交中...",
                        text: "",
                    });
                    setTimeout(function () {
                        var user = $api.getStorage("userSession")
                        $api.setStorage(
                            "userSession", user
                        );
                        openDetail("../../index.html");
                        api.closeWin({});
                    }, 5000);
                }
            },
        });
    }
</script>

</html>